package dnl.utils.swing;

import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.Window;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JDialog;

public class Dialog extends JDialog implements WindowListener {

	private boolean cancelled;

	public Dialog() {
		addWindowListener(this);
	}

	public Dialog(Frame owner) {
		super(owner);
		addWindowListener(this);
	}

	public Dialog(Dialog owner) {
		super(owner);
		addWindowListener(this);
	}

	public Dialog(Window owner) {
		super(owner);
		addWindowListener(this);
	}

	public Dialog(Frame owner, boolean modal) {
		super(owner, modal);
		addWindowListener(this);
	}

	public Dialog(Frame owner, String title) {
		super(owner, title);
		addWindowListener(this);
	}

	public Dialog(Dialog owner, boolean modal) {
		super(owner, modal);
		addWindowListener(this);
	}

	public Dialog(Dialog owner, String title) {
		super(owner, title);
		addWindowListener(this);
	}

	public Dialog(Window owner, ModalityType modalityType) {
		super(owner, modalityType);
		addWindowListener(this);
	}

	public Dialog(Window owner, String title) {
		super(owner, title);
		addWindowListener(this);
	}

	public Dialog(Frame owner, String title, boolean modal) {
		super(owner, title, modal);
		addWindowListener(this);
	}

	public Dialog(Dialog owner, String title, boolean modal) {
		super(owner, title, modal);
		addWindowListener(this);
	}

	public Dialog(Window owner, String title, ModalityType modalityType) {
		super(owner, title, modalityType);
		addWindowListener(this);
	}

	public Dialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) {
		super(owner, title, modal, gc);
		addWindowListener(this);
	}

	public boolean wasCancelled() {
		return cancelled;
	}
	
	protected void setCancelled(boolean cancelled){
		this.cancelled = cancelled;
	}

	@Override
	public void windowActivated(WindowEvent e) {

	}

	@Override
	public void windowClosed(WindowEvent e) {
	}

	@Override
	public void windowClosing(WindowEvent e) {
		cancelled = true;
	}

	@Override
	public void windowDeactivated(WindowEvent e) {

	}

	@Override
	public void windowDeiconified(WindowEvent e) {

	}

	@Override
	public void windowIconified(WindowEvent e) {

	}

	@Override
	public void windowOpened(WindowEvent e) {

	}

}
